package com.example.base.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.base.excetion.GlobalExcetion;
import com.example.base.system.domain.SysLongtext;
import com.example.base.system.mapper.SysLongtextMapper;
import com.example.base.system.service.SysLongtextService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author X.I.O
 * @since 2024-02-20
 */
@Service
@Transactional
@CacheConfig(cacheNames = "SysLongtextServiceImpl")
public class SysLongtextServiceImpl extends ServiceImpl<SysLongtextMapper, SysLongtext> implements SysLongtextService {

    @Cacheable(cacheNames = "syslongtext",key = "#id")
    @Override
    public SysLongtext getById(Serializable id){
        return super.getById(id);
    }

    @CacheEvict(cacheNames = "syslongtext", key = "#id")
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

    @CacheEvict(cacheNames = "syslongtext", key = "#syslongtext.id")
    @Override
    public boolean updateById(SysLongtext syslongtext) {
        return super.updateById(syslongtext);
    }

    @CachePut(cacheNames = "syslongtext", key = "#syslongtext.id")
    public SysLongtext saveSysLongtext(SysLongtext syslongtext) throws GlobalExcetion {
        super.save(syslongtext);
        return syslongtext;
    }

    @CacheEvict(cacheNames = "syslongtext", key = "#syslongtext.id")
    public SysLongtext updateSysLongtextById(SysLongtext syslongtext) throws GlobalExcetion{
        super.updateById(syslongtext);
        return syslongtext;
    }


}
